/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.ventas.web;



import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import tv.inventario.modelo.TipoProducto;
import tv.inventario.rn.TipoProductoRN;
import tv.venta.modelo.CondicionDePago;
import tv.ventas.rn.CondicionDePagoRN;

/**
 *
 * @author ctrosch
 */
@ManagedBean (name="conversoresVentas")
@SessionScoped
public class ConversoresVentas {
    
    @EJB private CondicionDePagoRN condicionDePagoRN;

    /** Creates a new instance of ConversoresBean */
    public ConversoresVentas() {
        
    }

    public Converter getCondicionDePago() {
        return new Converter() {

            @Override
            public Object getAsObject(FacesContext context, UIComponent component, String value) {
                if (value.trim().equals("") || value == null) {
                    return null;
                }

                CondicionDePago t = condicionDePagoRN.getCondicionDePago(value);
                return t;
            }

            @Override
            public String getAsString(FacesContext context, UIComponent component, Object value) {
                if (value == null || value.equals("")) {
                    return "";
                } else {

                    return ((CondicionDePago) value).getCndpag()+ "";
                }
            }
        };
    }

   
}
